package cn.sso.app.controller;

import cn.ifloat.brick.basic.common.accounts.Account;
import cn.ifloat.brick.basic.common.toolkit.beans.BeanUtils;
import cn.ifloat.brick.sprofile.sso.init.server.SsoIdentity;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.Map;

/**
 * @author: float 2023/2/25 14:02
 */
@Component
public class ExampleIdentity implements SsoIdentity<Account> {

    @PostConstruct
    public void init(){
        System.out.println(" init : exampleIdentity");
    }

    @Override
    public Account login(Map map) {
        Account account = new Account();
        account.setName("demoF");
        account.setId("111");
        account.setLoginTime("2023-11-11 11:11:11");
        account.setJobId("3");
        account.setOrgId("4");
        account.setTid("5");
        account.setDevice("WEB");
        account.setSuperAdmin(true);
        return account;
    }

    @Override
    public Map<String, Object> convert(Account account) {
        return BeanUtils.toMap(account);
    }

    @Override
    public Account convert(Map<String, Object> param) {
        Account account = new Account();
        BeanUtils.pushMapToBean(account, param);
        return account;
    }
}
